package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Category;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.domain.SetmealDish;
import com.itheima.reggie.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    //套餐列表展示
    @GetMapping("/setmeal/list")
    public ResultInfo findList(Long categoryId, Integer status) {
        //调用
        List<Setmeal> setmealsList = setmealService.findList(categoryId, status);
        //返回
        return ResultInfo.success(setmealsList);
    }

    //点击套餐 显示套餐信息
    @GetMapping("/setmeal/dish/{id}")
    public ResultInfo findBySetmealDish(@PathVariable Long id){
        //调用
        List<Dish> dishList =setmealService.findBySetmealDish(id);
        //返回
        return ResultInfo.success(dishList);
    }
}
